﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using DBControl;

namespace ProjectX
{
    public partial class detail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string pid = Request.QueryString["pid"];
                BindSource(pid, "");
            }

        }

        private void BindSource(string pid, string sqlwhere)
        {
            SqlDbHelper sdh = new SqlDbHelper(this.ConnString());
            this.myDetails.DataSource = sdh.ExecuteDataTable("SELECT * FROM BuyersinfoR WHERE id='" + pid + "'");
            this.myDetails.DataBind();
        }

        private void BindSeller(string pid)
        {
            
        }

        private string ConnString()
        {
            SystemLib sl = new SystemLib();
            string connStr = "";
            string datasource = ConfigurationManager.AppSettings["SqlServer"];
            string dataname = ConfigurationManager.AppSettings["SqlDataName"];
            string uid = ConfigurationManager.AppSettings["SqlUid"];
            string pwd = sl.Decrypto(ConfigurationManager.AppSettings["SqlPwd"]);
            connStr = "Data Source=" + datasource + ";Initial Catalog=" + dataname + ";User ID=" + uid + ";PassWord=" + pwd;
            return connStr;
        }

        protected void myDetails_DataBound(object sender, EventArgs e)
        {
            SqlDataSource sorce = this.myDetails.FindControl("sellListDatasorce") as SqlDataSource;
            sorce.ConnectionString = ConnString();
            sorce.SelectCommand = "SELECT * FROM Sellerinfomation WHERE BuyerID='" + Request.QueryString["pid"] + "'";

            //DataList mySellerList = this.myDetails.FindControl("SellerList") as DataList;
        }

        

    }
}